package moledata;

import Common.*;
import CoreClass.*;

/** 
 other ��ժҪ˵����
*/
public class tsaipyao
{

	public static String FullQihaor()
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		String tmp = "";
		String cyihaor = String.valueOf(Qihaor());


		if (Qihaor() > 72)
		{
			tmp = "end";

		}
		else
		{
			if (cyihaor.length() == 1)
			{
				cyihaor = "0" + cyihaor;
			}
			tmp = date("") + "-" + cyihaor;
		}
		return tmp;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}

	public static int Qihaor()
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		int hour = (java.time.LocalDateTime.now().getHour());
		int minute = (java.time.LocalDateTime.now().getMinute());
		int sec = java.time.LocalDateTime.now().getSecond();

		int startSecs = 9 * 3600 + 48 * 60 + 0;
		int NowSecs = hour * 3600 + minute * 60 + sec;
		int passSecs = (NowSecs >= startSecs) ? NowSecs - startSecs : NowSecs - startSecs + 24 * 3600;


		int qihao = (int)(Math.floor(new java.math.BigDecimal((passSecs / 600))) + 1);


		return qihao;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}

	public static int EndTime()
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region

		int minute = (java.time.LocalDateTime.now().getMinute());
		minute = minute % 10; // get last minute;
		int sec = java.time.LocalDateTime.now().getSecond();

		int startSecs = 8 * 60 + 0;
		int NowSecs = minute * 60 + sec;
		int passSecs = (NowSecs >= startSecs) ? NowSecs - startSecs : NowSecs - startSecs + 600; //600sec

		return 600 - passSecs;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}

	public static String date(String spa)

	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		String year = java.time.LocalDateTime.now().getYear().toString();
		String month = java.time.LocalDateTime.now().getMonthValue().toString().length() == 2?java.time.LocalDateTime.now().getMonthValue().toString():"0" + java.time.LocalDateTime.now().getMonthValue().toString();
		String day = java.time.LocalDateTime.now().getDayOfMonth().toString().length() == 2?java.time.LocalDateTime.now().getDayOfMonth().toString():"0" + java.time.LocalDateTime.now().getDayOfMonth().toString();
		return year + spa + month + spa + day;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion

	}


	public static int GetHezhiZhushu(int hezhi, int xinji)
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		String s = "";
		int num = hezhi;
		int i,j,k,n = 0;
		for (i = 0;i < 10;i++)
		{
			for (j = 0;j < 10;j++)
			{
				if (xinji == 2)
				{
					if (i + j == num)
					{
						s = s + " " + i + j;
						n++;
					}
				}
				else //xinji==3
				{
					for (k = 0;k < 10;k++)
					{
						if (i + j + k == num)
						{
							s = s + " " + i + j + k;
							n++;
						}
					}
				}
			}
		}

		return n;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}



	public static tsaipyao.a BankLog(int HyNum, java.math.BigDecimal Money, String Remark)
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		//�������ĳ�ʼ��ֵΪԭ�����������Ľ���
		String sqlUp = "update bank set Balance =Balance-" + Money + "  Where hy_num =" + HyNum;

		java.math.BigDecimal MoneyFu = Money.subtract(0);
		String sqllog = "insert into  bank_log (balance,bz,addtime,hy_num) values(" + MoneyFu + ",'" + Remark + "','" + java.time.LocalDateTime.now().toString() + "'," + HyNum + ")";
		a xx = new a();
		xx.BankSql = sqlUp;
		xx.LogSql = sqllog;
		return xx;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}



	public static class a
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		public String BankSql;
		public String LogSql;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}
	public static class o
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		public Object o1;
		public Object o2;
		public Object o3;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}





	public static boolean TimeOver(String qishu, System.Web.UI.Page Page)

	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region        TimeOver(string qishu) //_Ͷע����ʱ����,�Ƿ����
		int min = java.time.LocalDateTime.now().getMinute(); //�жϵ�ǰʱ���ǲ��� x 7 ֮��7֮��ֹͣͶע
		if (min % 10 >= 7)
		{
			Common.StaticClass.Alert(Page, "����Ͷע����ʱ���ѵ��ˣ���ȴ����ڡ�");
			return true;
		}
		if (qishu.equals("end"))
		{
			Common.StaticClass.Alert(Page, "����Ͷע����ʱ���ѵ�����������Ͷע��");
			return true;
		}

		return false;

		//___________________Ͷע����ʱ������ϡ�
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}


	public static boolean HeZhiOK(int xinji, int hezhi)
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		if (xinji == 2 && hezhi >= 0 && hezhi <= 18)
		{

			return true;

		}
		if (xinji == 3 & hezhi >= 0 & hezhi <= 27)
		{
			return true;

		}

		return false;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion

	}
	public static boolean MoneyEnable(int userID, java.math.BigDecimal Money, System.Web.UI.Page Page) //�ж��Ƿ������˻����㹻�Ľ��
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region //�ж��Ƿ������˻����㹻�Ľ��  �����õ�¼������datareader �ж���Ϊ�п��ܴ�ʱǮ�Ѿ�����

		CoreClass.DBCommon db2 = new DBCommon();
		String sqlBank2 = "";
		sqlBank2 = "select * from bank where hy_num = '" + userID + "'";
		SqlDataReader dr2 = db2.GetDataReaderBySql(sqlBank2);
		String balancestr = "";
		if (!dr2.Read())
		{
			return false;
		}
		balancestr = String.valueOf(dr2.getItem("balance"));
		//	int balanceint = int.Parse(balancestr);
		java.math.BigDecimal balanceDec = java.math.BigDecimal.Parse(balancestr);
		java.math.BigDecimal outall = java.math.BigDecimal.Parse(dr2.getItem("output_money").toString());



		//Trace.Warn("balancexx::"+balanceDec.ToString()); 



		//�ж��˻��Ƿ�ͣ��
		String bankZt = dr2.getItem("zt").toString();
		if (bankZt.equals("t"))
		{
			Common.StaticClass.Alert(Page, "�����˻������ᣬ��ʱ����Ͷע�������Ա��ϵ");
			return false;
		}



		//��������ж� 
		if (Money.compareTo(balanceDec) > 0)
		{
			Common.StaticClass.Alert(Page, "ϵͳ��ʾ�������˻����㣬���ֵ��");
			return false;
		}
		return true;
		//��������������������������ִ�п�Ǯ���
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}

	public static int GetID2(int xinji) //�õ�caizhongID2  ʱʱ�ʺ�ֵ���� 50120005        ʱʱ�ʺ�ֵ���� 50120006

	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		int tmp = 0;
		if (xinji == 3)
		{
			tmp = 50120005;
		}
		if (xinji == 2)
		{
			tmp = 50120006;
		}
		return tmp;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}


	public static int islogin(System.Web.UI.Page pag)
	{
		String userid = "";
		try
		{
			MOLE.comm.Alert(pag, "���ȵ�¼", "http://www.shishicai.cn/passport/Login.aspx");
			//System.Web.HttpContext.Current.Response.End();			
			//				userid= System.Web.HttpContext.Current.Request.Cookies["hy_numx"].Value;

		}
		catch (RuntimeException E)
		{
			MOLE.comm.Alert(pag, "���ȵ�¼", "http://www.shishicai.cn/passport/Login.aspx");
			System.Web.HttpContext.Current.Response.End();

		}
		MOLE.comm.Alert(pag, "���ȵ�¼", "http://www.shishicai.cn/passport/Login.aspx");
		return 1;


	}


	public static void log(String str)
	{


		String path = System.Web.HttpContext.Current.Server.MapPath("/") + "nl_log\\index.html";
		str = "<hr>" + str;
		MOLE.file.write(path, str);


	}



public static boolean IsShowToPrint(int i, int j, boolean isZhweihaor)
{
	if (isZhweihaor)
	{
		if (i == 0) //firs FOR start   o is show
		{
			//return "0";
			return true;
		}
		else
		{
			//return "1";
			return false;
		}
	}
	else
	{
		//return "0";
		return true;
	}

}
	public static String getCac(int i, boolean isZhweihaor)
	{
		if (isZhweihaor)
		{
			if (i == 0) //firs FOR start   o is show
			{
				return "0";
			}
			else
			{
				return "1";
			}
		}
		else
		{
			return "0";
		}
	}

	public static String IsDelCyihaor(String str)
	{
		//MOLE.SQL.connectionString=Cm818_Dg_ngailon.commx.getConnstr();
		String sql = "select top 200 qihao from qishu where zt='ͣ��' order by id desc";
		DataTable dt = MOLE.SQL.GetDataTable(sql);
		for (int i = 0;i < dt.Rows.size();i++)
		{
			if (str.trim().equals(dt.Rows[i]["qihao"].toString().trim()))
			{
				return dt.Rows[i]["qihao"].toString().trim();
			}

		}
		return "ok";


	}

	public static String UpdateOutmoney(int uid, java.math.BigDecimal addmoney)
	{
		String sqlUp = "update bank set output_money=output_money+" + addmoney.toString() + "   Where hy_num =" + String.valueOf(uid);
		return sqlUp;
	}

}